USE [master]
GO
/****** Object:  Database [MvcBlog]    Script Date: 12/02/2010 11:28:43 ******/
CREATE DATABASE [MvcBlog] ON  PRIMARY 
( NAME = N'MvcBlog', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\MvcBlog.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'MvcBlog_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\MvcBlog_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [MvcBlog] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [MvcBlog].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [MvcBlog] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [MvcBlog] SET ANSI_NULLS OFF
GO
ALTER DATABASE [MvcBlog] SET ANSI_PADDING OFF
GO
ALTER DATABASE [MvcBlog] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [MvcBlog] SET ARITHABORT OFF
GO
ALTER DATABASE [MvcBlog] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [MvcBlog] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [MvcBlog] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [MvcBlog] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [MvcBlog] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [MvcBlog] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [MvcBlog] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [MvcBlog] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [MvcBlog] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [MvcBlog] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [MvcBlog] SET  DISABLE_BROKER
GO
ALTER DATABASE [MvcBlog] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [MvcBlog] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [MvcBlog] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [MvcBlog] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [MvcBlog] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [MvcBlog] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [MvcBlog] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [MvcBlog] SET  READ_WRITE
GO
ALTER DATABASE [MvcBlog] SET RECOVERY SIMPLE
GO
ALTER DATABASE [MvcBlog] SET  MULTI_USER
GO
ALTER DATABASE [MvcBlog] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [MvcBlog] SET DB_CHAINING OFF
GO
USE [MvcBlog]
GO
/****** Object:  Table [dbo].[Role]    Script Date: 12/02/2010 11:28:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Role](
	[Role_ID] [int] IDENTITY(1,1) NOT NULL,
	[Rolename] [nvarchar](max) NOT NULL,
 CONSTRAINT [PK_Role] PRIMARY KEY CLUSTERED 
(
	[Role_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[User]    Script Date: 12/02/2010 11:28:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[User](
	[User_ID] [int] IDENTITY(1,1) NOT NULL,
	[Username] [nvarchar](max) NOT NULL,
	[Password] [nvarchar](max) NOT NULL,
	[Firstname] [nvarchar](max) NULL,
	[Lastname] [nvarchar](max) NULL,
	[Email] [nvarchar](max) NULL,
	[FK_Role_ID] [int] NOT NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[User_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Entry]    Script Date: 12/02/2010 11:28:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Entry](
	[Entry_ID] [int] IDENTITY(1,1) NOT NULL,
	[Subject] [nvarchar](max) NOT NULL,
	[Body] [nvarchar](max) NULL,
	[FK_User_ID] [int] NOT NULL,
	[CreateDate] [datetime] NOT NULL,
 CONSTRAINT [PK_Entry] PRIMARY KEY CLUSTERED 
(
	[Entry_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Comment]    Script Date: 12/02/2010 11:28:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Comment](
	[Comment_ID] [int] IDENTITY(1,1) NOT NULL,
	[FK_Entry_ID] [int] NOT NULL,
	[FK_User_ID] [int] NOT NULL,
	[CreateDate] [datetime] NOT NULL,
	[Body] [nvarchar](max) NULL,
 CONSTRAINT [PK_Comment] PRIMARY KEY CLUSTERED 
(
	[Comment_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Default [DF_Entry_CreateDate]    Script Date: 12/02/2010 11:28:44 ******/
ALTER TABLE [dbo].[Entry] ADD  CONSTRAINT [DF_Entry_CreateDate]  DEFAULT (getdate()) FOR [CreateDate]
GO
/****** Object:  Default [DF_Comment_CreateDate]    Script Date: 12/02/2010 11:28:44 ******/
ALTER TABLE [dbo].[Comment] ADD  CONSTRAINT [DF_Comment_CreateDate]  DEFAULT (getdate()) FOR [CreateDate]
GO
/****** Object:  ForeignKey [FK_User_Role]    Script Date: 12/02/2010 11:28:44 ******/
ALTER TABLE [dbo].[User]  WITH CHECK ADD  CONSTRAINT [FK_User_Role] FOREIGN KEY([FK_Role_ID])
REFERENCES [dbo].[Role] ([Role_ID])
GO
ALTER TABLE [dbo].[User] CHECK CONSTRAINT [FK_User_Role]
GO
/****** Object:  ForeignKey [FK_Entry_User]    Script Date: 12/02/2010 11:28:44 ******/
ALTER TABLE [dbo].[Entry]  WITH CHECK ADD  CONSTRAINT [FK_Entry_User] FOREIGN KEY([FK_User_ID])
REFERENCES [dbo].[User] ([User_ID])
GO
ALTER TABLE [dbo].[Entry] CHECK CONSTRAINT [FK_Entry_User]
GO
/****** Object:  ForeignKey [FK_Comment_Entry]    Script Date: 12/02/2010 11:28:44 ******/
ALTER TABLE [dbo].[Comment]  WITH CHECK ADD  CONSTRAINT [FK_Comment_Entry] FOREIGN KEY([FK_Entry_ID])
REFERENCES [dbo].[Entry] ([Entry_ID])
GO
ALTER TABLE [dbo].[Comment] CHECK CONSTRAINT [FK_Comment_Entry]
GO
/****** Object:  ForeignKey [FK_Comment_User]    Script Date: 12/02/2010 11:28:44 ******/
ALTER TABLE [dbo].[Comment]  WITH CHECK ADD  CONSTRAINT [FK_Comment_User] FOREIGN KEY([FK_User_ID])
REFERENCES [dbo].[User] ([User_ID])
GO
ALTER TABLE [dbo].[Comment] CHECK CONSTRAINT [FK_Comment_User]
GO
